import { AddFormatFunc, ifRuleType } from "../types";

AddFormatFunc<ifRuleType>({

	type: "IF",

	handle: (rule, FMC) => {
		return `if(${FMC(rule[1])}){\n${rule[2].map(item => FMC(item)).join("\n")}\n}${rule[3].map(item => `\nelse if(${FMC(item[1])}){\n${item[2].map(info => FMC(info)).join("\n")}\n}`).join("")}${rule[4].length === 0 ? "" : `\nelse{\n${rule[4][1].map(item => FMC(item)).join("\n")}\n}`}`;
	},

})
